<template>
	<view class="page">
		<u-navbar title="达成心愿" border @leftClick="$utils.back()" placeholder />
		<view class="body">
			<z-paging ref="paging" style="height: 100%;" :fixed="false" v-model="data" @query="query"
				:default-page-no="1" :default-page-size="10">
				<template v-if="loading">
					<view class="contentBox" v-for="item in 10" :key="item">
						<view style="width: 100rpx;height: 100rpx;border-radius: 100%;" class="Skeleton" />
						<view>
							<view style="width: 100rpx;height: 30rpx;;" class="Skeleton" />
							<view style="width: 200rpx;height: 30rpx;;" class="Skeleton" />
						</view>
						<view class="imageBox Skeleton" />
					</view>
				</template>
				<template v-eles>
					<view class="contentBox" v-for="item in data" :key="item.id">
						<u-avatar :src='item.user.avatar' size='100rpx' />
						<view>
							<view>
								{{item.wish.title}}
							</view>
							<view>
								实现：{{item.created_at | dateFormat}}
							</view>
						</view>
						<view class="imageBox">
							<view class="but">
								{{item.point}}
							</view>
							<image :src="item.wish.thumb_small" mode="aspectFill"></image>
						</view>
					</view>
				</template>
			</z-paging>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				loading: true,
			}
		},
		methods: {
			query(page, size) {
				let obj = {
					page,
					size
				}
				uni.showLoading({
					title: '加载中...'
				})
				this.$api.My.Fulfill(obj).then(res => {
					uni.hideLoading()
					this.$refs.paging.complete(res.data.wishes.data)
					this.loading = false
				}).catch(err => {
					uni.hideLoading()
					uni.$u.toast(err.data.message)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 0rpx 20rpx;
		height: 100vh;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 10rpx);
		/* 兼容 iOS 设备 */
		padding-bottom: calc(env(safe-area-inset-bottom) + 10rpx);
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
	}

	.body {
		flex: 1;
		overflow: hidden;
	}

	.imageBox {
		position: relative;
		width: 200rpx;
		height: 100rpx;
		border-radius: 8rpx;
		overflow: hidden;

		.but {
			position: absolute;
			top: 10rpx;
			left: 10rpx;
			border-radius: 100rpx;
			border: 1rpx solid #ddd;
			text-align: center;
			padding: 0 10rpx;
			box-sizing: border-box;
		}
	}

	.contentBox {
		display: flex;
		align-items: center;
		padding-bottom: 10rpx;
		border-bottom: 1rpx solid #f5f5f5;
		margin-top: 10rpx;

		>view:nth-child(2) {
			flex: 1;
			margin: 0 10rpx;
			display: flex;
			justify-content: space-between;
			flex-direction: column;
			height: 100rpx;
		}

		image {
			width: 200rpx;
			height: 100rpx;
			border-radius: 8rpx;

		}

	}
</style>